home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / c-lang / vbcc.lha / vbcc / opt.h < prev    next >
C/C++ Source or Header  |  1996-05-15  |  5KB  |  139 lines

  1. /*  $VER: vbcc (opt.h) V0.3     */
  2.  
  3. #include "vbc.h"
  4.  
  5. #define BSET(array,bit) (array)[(bit)/CHAR_BIT]|=1<<((bit)%CHAR_BIT)
  6. #define BCLR(array,bit) (array)[(bit)/CHAR_BIT]&=~(1<<((bit)%CHAR_BIT))
  7. #define BTST(array,bit) ((array)[(bit)/CHAR_BIT]&(1<<((bit)%CHAR_BIT)))
  8.  
  9. extern int gchanged;   /*  Merker, ob Optimierungslauf etwas geaendert hat */
  10. extern int norek;      /*  diese Funktion wird nicht rekursiv auf          */
  11. extern int nocall;     /*  diese Funktion kehrt nicht zum Caller zurueck   */
  12.  
  13. /*  temporary fuer verschiedene Bitvektoren */
  14. extern unsigned char *tmp;
  15.  
  16. /*  fuer aktive Variablen   */
  17. extern struct Var **vilist;
  18. extern unsigned int vcount;    /*  0..vcount-rcount-1: vars, vcount-rcount..vcount: DREFOBJs */
  19. extern unsigned int rcount;
  20. extern size_t vsize;
  21. extern unsigned char *av_globals,*av_address,*av_statics,*av_drefs;
  22. extern int report_dead_statements;
  23.  
  24. /*  fuer verfuegbare Definitionen   */
  25. extern unsigned int dcount;
  26. extern size_t dsize;
  27. extern struct IC **dlist;
  28. extern unsigned char **defs;       /*  gibt an, welche Definitionen, welche    */
  29.                             /*  Variablen definieren                    */
  30. /*  alle Definitionen, globaler oder Adr. fuer propagation etc.         */
  31. extern unsigned char *rd_globals,*rd_address,*rd_statics,*rd_drefs;
  32. /*  dasselbe fuer die undefs    */
  33. extern unsigned char *rd_defs,*rd_tmp,*rd_parms;
  34.  
  35. /*  fuer verfuegbare Ausdruecke */
  36. extern struct IC **elist;
  37. extern unsigned int ecount;
  38. extern size_t esize;
  39. extern unsigned char *ae_globals,*ae_address,*ae_statics,*ae_drefs;
  40.  
  41. /*  fuer verfuegbare Kopien */
  42. extern unsigned int ccount;
  43. extern size_t csize;
  44. extern struct IC **clist;
  45.  
  46. /*  alle Assignments, globaler oder Adr. fuer propagation etc.         */
  47. extern unsigned char *cp_globals,*cp_address,*cp_statics,*cp_drefs,*cp_act,*cp_dest;
  48. /*  alle Kopieranweisungen, die eine best. Variable als Quelle haben    */
  49. extern unsigned char **copies;
  50.  
  51.  
  52. struct flowgraph{
  53.     struct IC *start,*end;
  54.     struct flowgraph *normalout,*branchout;
  55.     struct flowlist *in;
  56.     int index;
  57.     /*  Letzter Block der Schleife, falls Block Start einer Schleife ist    */
  58.     struct flowgraph *loopend;
  59.     /*  Anzahl Funktionsaufrufe im Block/der Schleife   */
  60.     int calls,loop_calls;
  61.     /*  Bitvektoren fuer aktive Variablen   */
  62.     unsigned char *av_in,*av_out,*av_gen,*av_kill;
  63.     unsigned char *rd_in,*rd_out,*rd_gen,*rd_kill;
  64.     unsigned char *ae_in,*ae_out,*ae_gen,*ae_kill;
  65.     unsigned char *cp_in,*cp_out,*cp_gen,*cp_kill;
  66.     /*  Registervariablen   */
  67.     struct Var *regv[MAXR+1];
  68.     /*  Merker, ob Register gebraucht wurde; MACR+1 Bits    */
  69.     unsigned char regused[(MAXR+CHAR_BIT)/CHAR_BIT];
  70. };
  71.  
  72. extern unsigned int basic_blocks;
  73.  
  74. struct flowlist{
  75.     struct flowgraph *graph;
  76.     struct flowlist *next;
  77. };
  78.  
  79. int bvcmp(unsigned char *dest,unsigned char *src,size_t len);
  80. void bvunite(unsigned char *dest,unsigned char *src,size_t len);
  81. void bvintersect(unsigned char *dest,unsigned char *src,size_t len);
  82. void bvdiff(unsigned char *dest,unsigned char *src,size_t len);
  83. int compare_const(union atyps *q1,union atyps *q2,int t);
  84. int compare_objs(struct obj *o1,struct obj *o2,int t);
  85. void simple_regs(void);
  86. void remove_IC_fg(struct flowgraph *g,struct IC *p);
  87.  
  88. extern int lastlabel;
  89.  
  90. struct flowgraph *construct_flowgraph(void);
  91. void print_av(unsigned char *bitvector);
  92. void print_rd(unsigned char *bitvector);
  93. void print_ae(unsigned char *bitvector);
  94. void print_cp(unsigned char *bitvector);
  95. void print_flowgraph(struct flowgraph *g);
  96. void free_flowgraph(struct flowgraph *g);
  97. void num_vars(void);
  98. void print_vi(void);
  99. void av_change(struct IC *p,unsigned char *use,unsigned char *def);
  100. void active_vars(struct flowgraph *fg);
  101. int dead_assignments(struct flowgraph *fg);
  102. void insert_IC(struct IC *p,struct IC *new);
  103. void insert_IC_fg(struct flowgraph *fg,struct IC *p,struct IC *new);
  104. void insert_allocreg(struct flowgraph *fg,struct IC *p,int code,int reg);
  105.  
  106. extern struct Var *lregv[MAXR+1];
  107. extern struct flowgraph *lfg;
  108.  
  109. extern int report_weird_code;
  110.  
  111. int replace_local_reg(struct obj *o);
  112. void local_regs(struct flowgraph *fg);
  113. void loop_regs(struct flowgraph *fg);
  114. void block_regs(struct flowgraph *fg);
  115. void insert_saves(void);
  116. struct flowgraph *jump_optimization(void);
  117. void num_defs(void);
  118. void reaching_definitions(struct flowgraph *fg);
  119. void calc(int c,int t,union atyps *q1,union atyps *q2,union atyps *z);
  120. int fold(struct IC *p);
  121. int peephole(void);
  122. int propagate(struct obj *o,int replace);
  123. int constant_propagation(struct flowgraph *fg,int global);
  124. int compare_exp(const void *a1,const void *a2);
  125. void num_exp(void);
  126. void available_expressions(struct flowgraph *fg);
  127. void available_copies(struct flowgraph *fg);
  128. int cse(struct flowgraph *fg,int global);
  129. void num_copies(void);
  130. int copy_propagation(struct flowgraph *fg,int global);
  131. void loops(struct flowgraph *fg,int mode);
  132. struct flowgraph *create_loop_headers(struct flowgraph *fg);
  133. struct flowgraph *create_loop_footers(struct flowgraph *fg);
  134. void insert_regs(struct flowgraph *fg);
  135. void recalc_offsets(struct flowgraph *fg);
  136. void optimize(long flags,struct Var *function);
  137.  
  138.  
  139.